<?php
class HomesController extends AppController {

	public function display(){
        parent::init();
        $this->loadModel('News');
        $this->loadModel('Category');
        
        // Lấy tin tức theo ngày giảm dần
        $news = $this->News->find('all', array(
            'order' => 'News.date DESC',
        ));
        
        if($news){
           $this->set('news', $news);
        }else{
            throw new NotFoundException(__('Invalid news'));
        }
	}
    
    /**
    public function view(){
        parent::init();
        $slug = $this->params['url']['slug'];
        $news = $this->News->find('first', array(
            'conditions' => array('News.slug' => $slug)
        ));
        if($news){
            $this->set('news', $news);
        }else{
            throw new NotFoundException(__('Invalid slug'));
        }
    }
    **/
}
